home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / SpriteEngine / SpriteTools.h < prev   
Text File  |  1995-03-11  |  2KB  |  56 lines

  1. // SpriteTools.h
  2.  
  3. #include <QDOffScreen.h>
  4. #include "SpriteHandlers.h"
  5.  
  6. #define    DoError    {SysBeep(1);ExitToShell();}
  7. #define abs(x)    ((x)>0?(x):-(x))
  8. #define Sgn(x) (x=0?0:(x>0?1:-1))
  9.  
  10. // Delay constant
  11. #define    kFrameTime    1
  12.  
  13. /* The window pointer */
  14. extern WindowPtr myWindow;
  15.  
  16. /****************************************/
  17. /* Global variables for sprite handling */
  18. /****************************************/
  19.  
  20. // EntityType and SpriteRecord are defined in SpriteHandlers.h
  21.  
  22. typedef SpriteRecord *SpritePtr;        /* Define a handle type to it */
  23.  
  24. /* A global pointer is the root of the entity list */
  25. extern SpritePtr    gSpriteList;
  26.  
  27. /* GWorlds for the animation and background buffers */
  28. extern GrafPtr gOffScreen, gBackScreen;
  29.  
  30. /*** End of sprite handling variables ***/
  31.  
  32. // Routines in SpriteTools.c
  33. void MyNewGWorld(GrafPtr *offscreenGWorld, Rect *boundsRect);
  34. GrafPtr LoadFaceFromCicn(short cicnId);
  35. void PlotFace(GrafPtr theCicn, GrafPtr destPort, Point where);
  36.  
  37. /*Sprite list management*/
  38. SpritePtr NewSprite();
  39. void DisposeSprite(SpritePtr who);
  40.  
  41. /*Sprite utilities*/
  42. Boolean KeepOnScreen(SpritePtr theSprite);
  43. #ifdef _hasfixedpoint
  44. Boolean KeepOnScreenFixed(SpritePtr theSprite);
  45. #endif
  46. short RectSeparate(SpritePtr theSprite, SpritePtr anotherSprite);
  47. short Rand(short range);
  48. Boolean    RegionHit(SpritePtr theSprite, SpritePtr anotherSprite);
  49. void SplitVector(Point v, Point d, Point *p, Point *n);
  50.  
  51. // Mandatory routines in SpriteHandlers.c
  52. void MoveSprite(SpritePtr theSprite);
  53. void HitSprite(SpritePtr theSprite, SpritePtr anotherSprite);
  54. void InitSprites();
  55.  
  56.